#include <iostream>

using namespace std;

const int N = 25000000;

int primes[N], cnt;
bool st[N];

void get_primes(int n) {
    for (int i = 2; i <= n; ++i) {
        if (!st[i]) primes[cnt++] = i;
        for (int j = 0; primes[j] * i <= n; ++j) {
            st[primes[j] * i] = true;
            if (i % primes[j] == 0) break;
        }
    }
}

bool is_prime(int x) {
    if (x < 2) return false;
    for (int i = 2; i <= x / i; ++i) {
        if (x % i == 0) return false;
    }
    return true;
}

bool check(int n) {
    while (n) {
        if (!is_prime(n % 10)) return false;
        n /= 10;
    }
    return true;
}

int main() {
    get_primes(100);
    int res = 0;

    cout << check(29);
    return 0;
} 